<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      lang="zh_CN">
<meta charset="utf-8">
<head>
    <meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
    <title>注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
	<link rel="stylesheet" href="/css/luo/css/style.css">

</head>
<body style="background-image: url(/img/sx.png);background-repeat:no-repeat;background-size:100% 100%;background-attachment: fixed;">
	
	<div id="main" style="display: none;" class="register-container">
		<h1>注册账号</h1>
		<div style="margin-top: 18px;">
			
			<p><a href="#" onclick="login()">已有账号？点击登录</a></p>
		</div>
		<form action="" method="post" id="fm">
			<input id="inviteUserId" name="inviteUserId" type="hidden" th:value="${user.userId}"/>
			<div>
				<input type="text" name="account" placeholder="账号"/>
				<p style="color: red;margin: 5px;text-align: left;font-size: 12px;">PS：该账号与注册成功之后跳转的网站一致，如果前往的网站已存在该账号，请回来重新注册。</p>
			</div>
			<div>
				<input type="text" name="tel" placeholder="手机号码" />
				<p style="color: red;margin: 5px;text-align: left;font-size: 12px;">PS：正确的手机号码，对于以后红包或者其他优惠的通知可以正常的接受短信通知。</p>
			</div>
			<div>
				<input type="text" name="nickname" placeholder="昵称"/>
			</div>
			<div>
				<input type="password" name="password" placeholder="密码"/>
				<!-- <p style="color: red;margin: 5px;text-align: left;font-size: 12px;">PS：该密码和前往的网站无关。</p> -->
			</div>
			<div>
			    <div style="width: 170px;float:left;"><input type="text" maxlength="4" name="code" placeholder="验证码" style="width: 170px;"/></div>
			    <div style="width: 96px;float:right;margin-top: 28px;"><a href="javascript:void(0);" title="点击更换验证码">
			            <img id="imgVerify" src='/wx/getVerify?Math.random()' alt="更换验证码" height="36" width="95px;" onclick="getVerify(this);">
			        </a></div>
			    
			        
			</div>
			<div style="margin-top: 98px;text-align: left;margin-left: 10px;">
				<p th:text="'推荐人账号：'+ ${user.username}"></p>
			</div>
			<button type="button" onclick="add()" >注 册</button>
		</form>
	</div>
</body>
<script src="/js/luo/js/jquery.min.js"></script>
<script>
	function add() {
		$.ajax({
			cache : true,
			type : "POST",
			url : "/wx/add",
			data : $('#fm').serialize(),// 你的formid
			async : false,
			error : function(request) {
				alert('网络出错');
			},
			success : function(data) {
				if (data.code == 0) {
					alert('注册成功，即将前往网站');
					location.href = data.msg;
				} else {
					//$('#msg').text(data.msg);
					alert(data.msg);
				}
			}
		});
	}
	function login() {
		location.href = "/wx/register?userId=" + $('#inviteUserId').val();
	}
	//获取验证码
	function getVerify(obj){
	    obj.src = "/wx/getVerify?"+Math.random();
	}
</script>
	<script type="text/javascript">
	var ua = navigator.userAgent.toLowerCase();
	var isWeixin = ua.indexOf('micromessenger') != -1;
	if (isWeixin) {
		$('#main').hide();
		document.body.style.background = "background-image: url(/img/sx.png);background-repeat:no-repeat;background-size:100% 100%;background-attachment: fixed;";
	}else{
		$('#main').show();
		document.body.style.background = "";
	}
	</script>
</html>